#ifndef TASKRECORD_H
#define TASKRECORD_H

#include <QObject>
#include <QSqlRecord>

class TaskRecord : public QObject
{
    Q_OBJECT
public:
    enum status_t {
        NEW,
        DOWNLOADING,
        COMPLETED,
        ERROR
    };
private:
    int id_;
    QSqlRecord* record;
    QString url_;
    QString path_;
    int priority_;
    status_t status_;

    void initFields();
public:
    explicit TaskRecord(QObject* parent = 0);
    TaskRecord(const QString& url, const QString& path, int priority, QObject* parent = 0);

    void setId(int id);
    int getId() const;
    QSqlRecord& getRecord() const;
    QString getURL() const;
    QString getPath() const;
    int getPriority() const;
    void resetStatus();

    void updateStatus(status_t status);
signals:
    void taskUpdated(int id, QSqlRecord* record);
public slots:
    void updateProgress(qint64 bytesReceived, qint64 bytesTotal);
};

#endif // TASKRECORD_H
